package com.ycsj.goldmedalnewconcept.teacher.adapter;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.makeramen.roundedimageview.RoundedImageView;
import com.ycsj.common.base.CommonAdapter;
import com.ycsj.common.base.ViewHolder;
import com.ycsj.common.image.ImageUtil;
import com.ycsj.goldmedalnewconcept.R;
import com.ycsj.goldmedalnewconcept.teacher.bean.WorkInfo;

import java.util.List;

/**
 * Created by Administrator on 2019/3/19 0019.
 */

public class WorkGvAdapter extends CommonAdapter<WorkInfo.ListBean> {

    private Context context;

    public WorkGvAdapter(Context context, List<WorkInfo.ListBean> datas, int layoutId) {
        super(context, datas, layoutId);
        this.context = context;
    }

    @Override
    public void convert(ViewHolder holder, final WorkInfo.ListBean listBean) {
        //头像
        RoundedImageView lvHead = holder.getView(R.id.lv_head);
        ImageUtil.displayImage(context, lvHead, listBean.getIcon(), R.drawable.head_default);

        //名称
        TextView tvName = holder.getView(R.id.tv_name);
        tvName.setText(listBean.getName());
        //外层选中
        LinearLayout llOut = holder.getView(R.id.ll_out);

        //状态
        ImageView lvState = holder.getView(R.id.lv_delete);

        //根据选中状态设置选中状态的值
        //根据选中状态设置选中状态的值
        if (listBean.flag) {
            lvState.setVisibility(View.VISIBLE);
            lvState.setImageResource(R.drawable.checked);
        } else {
            lvState.setVisibility(View.VISIBLE);
            lvState.setImageResource(R.drawable.unchecked);
        }
        llOut.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                listBean.flag = !listBean.flag;
                notifyDataSetChanged();
            }
        });
    }
}
